//  表单项配置
var fComfig = {
    //  加载表单项-横版
    loadFormList: function (dataType, myForm) {
        myForm = myForm || "hidFromItem";
        var jsonFrom = fComfig.loadFormData(dataType);
        $.each(jsonFrom, function (i, e) {
            var strHtml = "";
            strHtml += '<div class="form-group" ' + (!e.dName || "name='" + e.dName + "'") + '>';
            strHtml += '    <label class="col-sm-3 control-label" ' + (!e.required || "l='spot'") + '>' + e.title + '：</label>';
            strHtml += '    <div class="col-sm-8">';
            //  表单渲染
            strHtml += fComfig.getFromItem(e);
            strHtml += '    </div>';
            strHtml += '</div>';
            $("#" + myForm).before(strHtml);
        });
    },
    //  加载表单项-纵版release
    loadRFormList: function (dataType, myForm) {
        myForm = myForm || "hidFromItem";
        var jsonFrom = fComfig.loadFormData(dataType);
        $.each(jsonFrom, function (i, e) {
            var strHtml = "";
            if (e.type == "heading") {
                strHtml += '  <h4 class="col-sm-12" style="color: #9E792E">' + e.title + '</h4>';
            } else {
                strHtml += '<div class="form-group col-sm-' + (e.cell || 12) + '" ' + (!e.dName || "name='" + e.dName + "'") + '>';
                strHtml += '    <label ' + (!e.required || "l='spot'") + '>' + e.title + '</label>';
                //  表单渲染
                strHtml += fComfig.getFromItem(e);
                strHtml += '</div>';
            }
            $("#" + myForm).before(strHtml);
        });
    },
    //  表单渲染
    getFromItem: function (e) {
        var strHtml = "";
        switch (e.type) {
            case "select":
                strHtml += '<select  id="' + e.name + '" name="' + e.name + '" ' + (!e.required || "required") + ' ' + (e.onChange || "") + ' class="form-control">';
                $.each(e.data, function (j, d) {
                    strHtml += '<option id="' + e.name + '" value="' + d.value + '">' + d.text + '</option>'
                });
                strHtml += '</select>';
                break;
            case "treeSelect":
                strHtml += '<div class="treeSelect" style="width: 100%;"></div>';
                break;
            case "textarea":
                strHtml += '<textarea id="' + e.name + '" name="' + e.name + '" ' + (!e.maxlength || 'maxlength="' + (e.maxlength) + '"') + '  class="form-control" ' + (!e.required || "required") + ' type="text" rows="2"></textarea>';
                break;
            default:
                strHtml += '<input id="' + e.name + '" name="' + e.name + '" '+ (e.disabled ? 'disabled' : '') +' ' + (!e.maxlength || 'maxlength="' + (e.maxlength) + '"') + '  class="form-control '+(!e.isreset || 'no-reset')+'" ' + (!e.required || "required") + ' type="text">';
                break;
        }
        return strHtml;
    },
    //  加载表单项数据
    loadFormData: function (dataType) {
        var jsonFrom = [];
        switch (dataType) {
            case "menus":   //  菜单
                jsonFrom = [
                    {
                        title: '菜单名称',
                        name: 'menuname',
                        required: true,
                        type: 'text',
                        maxlength: 20
                    },
                    {
                        title: '跳转路径',
                        name: 'jumpurl',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: 'Icon样式',
                        name: 'iconstyle',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '排序ID',
                        name: 'orderbyid',
                        required: false,
                        type: 'text'
                    }
                ];
                break;
            case "cus":   //  客户档案
                jsonFrom = [
                    {
                        title: '基础信息',
                        type: 'heading'
                    },
                    {
                        title: '客户名称',
                        name: 'cusname',
                        required: true,
                        type: 'text',
                        maxlength: 50
                    },
                    {
                        title: '客户分类',
                        name: 'cusclass',
                        required: false,
                        disabled: true,
                        isreset: true,
                        type: 'text',
                        cell: 6
                    },
                    {
                        title: '客户类型',
                        name: 'custype',
                        required: false,
                        type: 'select',
                        cell: 6,
                        data: []
                    },
                    {
                        title: '客户来源',
                        name: 'treeSelect',
                        required: true,
                        type: 'treeSelect',
                        cell: 4
                    },
                    {
                        title: '询盘时间',
                        name: 'firstdate',
                        required: true,
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '首单年月',
                        name: 'firstorder',
                        required: true,
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '联系人',
                        type: 'heading'
                    },
                    {
                        title: '联系人',
                        name: 'contacts',
                        required: true,
                        type: 'text',
                        cell: 3
                    },
                    {
                        title: '手机',
                        name: 'mobile',
                        required: true,
                        type: 'text',
                        cell: 3
                    },
                    {
                        title: '电话',
                        name: 'phone',
                        required: true,
                        type: 'text',
                        cell: 3
                    },
                    {
                        title: 'Email',
                        name: 'email',
                        required: true,
                        type: 'email',
                        cell: 3
                    },
                    {
                        title: '个人喜好',
                        name: 'personallike',
                        required: true,
                        type: 'textarea',
                        maxlength: 100
                    },
                    {
                        title: '地址信息',
                        type: 'heading'
                    },
                    {
                        title: '客户分布',
                        name: 'cusdis',
                        required: true,
                        type: 'select',
                        cell: 4,
                        data: []
                    },
                    {
                        title: '国家',
                        name: 'province',
                        required: true,
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '州',
                        name: 'city',
                        required: true,
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '地址',
                        name: 'address',
                        required: true,
                        type: 'text'
                    },
                    {
                        title: '公司信息',
                        type: 'heading'
                    },
                    {
                        title: '公司规模',
                        name: 'companyscale',
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '部门数量',
                        name: 'deptcount',
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '客户群体',
                        name: 'customergroup',
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '经营范围',
                        name: 'scopebusiness',
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '经营产品',
                        name: 'scopeproduct',
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '关注产品',
                        name: 'attentionproduct',
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '组织架构',
                        name: 'zzjg',
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '年采购量',
                        name: 'purchasercount',
                        type: 'text',
                        cell: 4
                    },
                    {
                        title: '备注',
                        name: 'remarks',
                        type: 'textarea',
                        maxlength: 100
                    }
                ];
                break;
            case "orderType":   //  工单类型
                jsonFrom = [
                    {
                        title: '类型名称',
                        name: 'tname',
                        required: true,
                        type: 'text',
                        maxlength: 20
                    },
                    {
                        title: '类别',
                        name: 'tclass',
                        required: true,
                        type: 'select',
                        data: [{value: '0', text: "指派"}, {value: '1', text: "认领"}],
                        onChange: "onchange=changeTclass(this)"
                    },
                    {
                        title: '部门',
                        name: 'iconstyle',
                        required: true,
                        type: 'treeSelect',
                        dName: 'divShow'
                    },
                    {
                        title: '时间',
                        name: 'ttimes',
                        required: true,
                        type: 'text',
                        dName: 'divShow'
                    },
                    {
                        title: '是否支持退单',
                        name: 'rstatus',
                        required: true,
                        type: 'select',
                        data: [{value: '0', text: "否"}, {value: '1', text: "是"}]
                    },
                    {
                        title: '备注',
                        name: 'remarks',
                        required: false,
                        type: 'textarea'
                    },
                ];
                break;
            case "tasklst":     // 新增任务表单
                jsonFrom = [
                    {
                        title: '任务发起',
                        type: 'heading'
                    },
                    {
                        title: '任务内容',
                        name: 'taskcontent',
                        required: true,
                        type: 'textarea'
                    },
                    {
                        title: '派发人',
                        name: 'sendtaskuser',
                        required: false,
                        type: 'text',
                        disabled: true,
                    },
                    {
                        title: '执行人',
                        name: 'maketaskuser',
                        required: true,
                        type: 'text'
                    },
                    {
                        title: '任务发起时间',
                        name: 'taskfirstdate',
                        required: false,
                        type: 'text',
                        disabled: true,
                    },
                    {
                        title: '计划完成时间',
                        name: 'taskplanenddate',
                        required: true,
                        type: 'text',
                    },
                    {
                        title: '任务执行',
                        type: 'heading'
                    },
                    {
                        title: '阶段反馈时间',
                        name: 'taskfeedbackdate',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '阶段反馈',
                        name: 'taskfeedback',
                        required: false,
                        type: 'textarea'
                    },
                    {
                        title: '实际完成时间',
                        name: 'taskenddate',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '任务完成反馈',
                        name: 'taskendfeedback',
                        required: false,
                        type: 'textarea'
                    },
                    {
                        title: '逾期反馈时间',
                        name: 'latefeedbackdate',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '逾期内容反馈',
                        name: 'overduefeedback',
                        required: false,
                        type: 'textarea'
                    },
                ];
                break;
            case "inquiry":
                jsonFrom = [
                    {
                        title: '基础信息(销售填)',
                        type: 'heading'
                    },
                    {
                        title: '询价日期',
                        name: 'inquirydate',
                        type: 'text',
                        disabled: true
                    },
                    {
                        title: '国家',
                        name: 'country',
                        required: true,
                        type: 'text'
                    },
                    {
                        title: '公司名称',
                        name: 'company',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '物流',
                        name: 'logistics',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '重量(kg)',
                        name: 'goodsweight',
                        required: true,
                        type: 'text'
                    },
                    {
                        title: '双清',
                        name: 'liquidation',
                        required: false,
                        type: 'select',
                        data: [{value: '0', text: "是"}, {value: '1', text: "否"}]
                    },
                    {
                        title: '报关',
                        name: 'goodsdeclare',
                        required: false,
                        type: 'select',
                        data: [{value: '0', text: "是"}, {value: '1', text: "否"}]
                    },
                    {
                        title: '货代信息(客服填)',
                        type: 'heading'
                    },
                    {
                        title: '询价货代',
                        name: 'forwarder',
                        required: false,
                        type: 'text'
                    },

                    {
                        title: '询价金额(RMB)',
                        name: 'inquiryprice',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: 'T6金额(RMB)',
                        name: 't6price',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '报价(RMB)',
                        name: 'logisticsprice',
                        required: false,
                        type: 'text'
                    },

                    {
                        title: '双清金额(RMB)',
                        name: 'liquidationprice',
                        required: false,
                        type: 'text',
                        disabled: false
                    },

                    {
                        title: '报关金额(RMB)',
                        name: 'goodsdeclareprice',
                        required: false,
                        type: 'text',
                        disabled: false
                    },
                    {
                        title: '时效(天)',
                        name: 'ageing',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '限电/风险',
                        name: 'risk',
                        required: false,
                        type: 'select',
                        data: [{value: '0', text: "是"}, {value: '1', text: "否"}]
                    },
                    {
                        title: '单号',
                        name: 'waybill',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '销售人员',
                        name: 'sales',
                        required: false,
                        type: 'text',
                        disabled: true
                    },
                    {
                        title: '货代人员',
                        name: 'forwarderstaff',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '实发金额(RMB)',
                        name: 'actualprice',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '实发重量(RMB)',
                        name: 'actualweight',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '转运单号',
                        name: 'transferwaybill',
                        required: false,
                        type: 'text'
                    },
                    {
                        title: '汇率(%)',
                        name: 'rate',
                        required: false,
                        type: 'text'
                    }
                ]
        }
        return jsonFrom;
    }
}